The DiagramSurface Control

The DiagramSurface control is the core control for WPF Diagrams. To display a diagram in your application, create a DiagramSurface control and set its DiagramSurface.Diagram property.

DiagramSurface has a number of properties which you can use to configure the behaviour and appearance of the diagram. The following list summarises key properties:

Visual style properties
MarqueeStyle The style for selection rectangles (when the user drags over an area to select).
SnapLineDrawing Controls the drawing of snap lines on the background. See Background.
DefaultCreateConnectionLineStyle Used when the user is creating a connection, and no specific style is provided for the tool being used
Formatter Controls diagram visual style in the low-level API. See Formatting.
Scrolling properties
IsSmartScrollingEnabled Scrolls the viewport as the user moves items.
OverflowBehavior Controls whether the user is allowed to scroll when the diagram already fits within the control.
Editing properties
IsReadOnly Prevents the user making changes to the diagram.
ShowConnectionPoints Controls whether connection points are displayed.
SelectionMode Controls whether the surface allows single or multiple selection.
Zoom properties
Zoom The current zoom level.
ZoomMode Controls how the user can change the zoom level.
Snapping properties
HorizontalSnapSpecifier Controls horizontal snapping behaviour. See Snapping.
VerticalSnapSpecifier Controls vertical snapping behaviour. See Snapping.
Collision control properties
AllowNodeCollisions Controls whether nodes can overlap.
AllowSegmentToNodeCollisions Controls whether nodes and connections can overlap.
CollisionBuffer Controls the minimum distance between nodes and connections.

DiagramSurface also exposes several properties and methods which are not related to appearance or behaviour but may be important when using the control in a broader application context:

Contained UI elements
DiagramElements The UI elements representing the contents of the diagram.
NodeElements The UI elements for the diagram nodes.
ConnectionElements The UI elements for the diagram connections.
ScrollViewer The scroll viewer used for scrolling the diagram viewport.
Selection properties
SelectedItem The currently selected diagram model item.
SelectedItems The collection of currently selected diagram model items.
SelectedElement The currently selected diagram element (UI element).
SelectedElements The collection of currently selected diagram elements (UI elements).
Diagram status
IsDirty Whether the diagram displayed on the surface has been changed.